﻿using FairyGUI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using WgFrame.Net;

public class FlyTextPanel : BaseFlyPanel
{
    private GTextField tfText;
    private Transition t0;
    private float defY;

    public override void Init()
    {
        base.Init();
        tfText = view.GetChild("n1").asTextField;
        t0 = view.GetTransition("t0");
        view.Center();
        defY = view.y;
    }

    public override void Show(params object[] para)
    {
        t0.Stop();
        tfText.text = (string)para[0];
        view.Center();
        view.y = defY;
        t0.Play(OnPlayComplete);

        base.Show(para);
    }

    private void OnPlayComplete()
    {
        Close();
        FlyTextPanelMgr.Recycle(this);
    }

    protected override GComponent CreateView()
    {
        return UIPackage.CreateObject("Main", "panel_flytext").asCom;
    }
}
